import { GLFolderLike } from './GLFolderLike';
import { GLItem } from './GLItem';
import { GLBookChapter } from './GLBookChapter'

export class GLBookContent extends GLFolderLike {
  private content: GLItem[];

  constructor(data, parentFolder?: GLFolderLike) {
    super(parentFolder, data.name || data.title, data.uri);

    this.content = (data.nodes || []).map((node): GLItem => {
      if (node.content) {
        return new GLBookChapter(node, this);
      }
      return new GLBookContent(node, this);
    });
  }

  getContent() {
    return this.content;
  }
}
